$('.top-return-btn').on('click', function (event) {
  event.stopPropagation();
  window.history.go(-1);
});

$('.subject .c-list').on('click', 'li', function (event) {
  event.stopPropagation();
  $(this).addClass('active').siblings().removeClass('active');
});

/* 题目选择 */
$('#js-subject-select').on('click', 'li', function (event) {
  event.stopPropagation();
  $(this).toggleClass('active').siblings().removeClass('active');
  if ($('#js-subject-select li').hasClass('active')) {
    $('.subject-content').addClass('active')
  } else {
    $('.subject-content').removeClass('active')
  }
});

/* 收藏题目 */
$('#js-collection').on('click', function (event) {
  event.stopPropagation();
  $('.dialog-mask').addClass('active');
  $('#js-open-subject').addClass('active');
});

/* 输入题目 */
$('#completeBtn').on('click', function (event) {
  event.stopPropagation();
  $('#js-open-subject').removeClass('active');
  $('.dialog-mask').addClass('active');
  $('#js-add-subject').addClass('active');
});

/* 关闭 */
$('.closeAllDialog').on('click', function (event) {
  event.stopPropagation();
  $('.dialog-mask').removeClass('active');
  $('.dialog-box').removeClass('active');
});

/* 选择题库 */
$('#js-add-subject').on('click', 'li', function (event) {
  event.stopPropagation();
  $(this).siblings().removeClass('active');
  $(this).addClass('active');
});

/* 答案解析tab */
$('.analysis .btn-box').on('click', '.btn', function (event) {
  event.stopPropagation();
  var $index = $(this).index();
  $(this).addClass('active').siblings().removeClass('active');
  $('.analysis .item-box').eq($index).addClass('active').siblings().removeClass('active');
});

/* 排行榜 */
$('.rank-box .tab-btn').on('click', 'li', function (event) {
  event.stopPropagation();
  $(this).addClass('active').siblings().removeClass('active');
  var $this = $(this).index();
  $('.rank-box .tab-wrap-box').eq($this).addClass('active').siblings().removeClass('active');
});

/* 马原考点 */
$('#js-examination-list').on('click', '.f-btn', function (event) {
  event.stopPropagation();
  $(this).find('.pos').toggleClass('active');
  $(this).find('.content').toggleClass('active');
  $(this).siblings('li').find('.pos').removeClass('active');
  $(this).siblings('li').find('.content').removeClass('active');
});

/* 题目解析 */
$('.analysis-more').on('click', function (event) {
  event.stopPropagation();
  $('.dialog-mask').addClass('active');
  $('.dialog-analysis-box').addClass('active');
});

/* 题目解析选择题目 */
$('.dialog-analysis-box #js-a-list').on('click', 'li', function (event) {
  event.stopPropagation();
  $(this).addClass('active');
  $(this).siblings('li').removeClass('active');
  $('.dialog-mask').removeClass('active');
  $('.dialog-box').removeClass('active');
});

/* 错题集tab切换 */
$('.fail-test-box .tab-btn').on('click', 'li', function (event) {
  event.stopPropagation();
  var $index = $(this).index();
  $(this).addClass('active').siblings().removeClass('active');
  $('.fail-test-box .tab-item').eq($index).addClass('active').siblings().removeClass('active');
});

/* 错题集考点刷题tab切换 */
$('.s-tab-box').on('click', 'li', function (event) {
  event.stopPropagation();
  var $index = $(this).index();
  $(this).find('.s-item').addClass('active');
  $(this).siblings('li').find('.s-item').removeClass('active');
  $('.tab-con-box .list-box').eq($index).addClass('active').siblings().removeClass('active');
});

/* 只复习错题样式切换 */
$('.onlyFailSubject').on('click', function (event) {
  event.stopPropagation();
  $(this).toggleClass('active');
});

/* 答题卡 */
$('.answer-box').on('click', function (event) {
  event.stopPropagation();
  $('.dialog-mask').addClass('active');
  $('#js-answer-dialog-box').addClass('active')
});


$('.my-progress-wrap').each(function (index, item) {
  var rate = parseInt($(item).find(".rate").html());
  var num = rate * 3.6;
  if (num < 180) {
    $(item).find(".left").css("transform", "rotate(" + num + "deg)");
  } else {
    $(item).find(".left").css("transform", "rotate(180deg)");
    $(item).find(".right").css("transform", "rotate(" + (num - 180) + "deg)");
  }

  if (rate > 100) {
    $(item).find(".rate").html(100);
    $(item).find(".right").css("transform", "rotate(180deg)");
  }
});

layui.use('layer', function () {
  var layer = layui.layer;
  /* 专属题库删除 */
  $('.my-test-box').on('click', '.closeBtn', function (event) {
    event.stopPropagation();
    layer.open({
      title: '',
      type: 1,
      closeBtn: 0, //不显示关闭按钮
      area: ['72%', '128px'], //宽高
      content: $('#js-close-box-wrap'),
      success: function ($dom, index) {
        $($dom).addClass('myLayer')

        /* 取消按钮关闭弹窗 */
        $('.close-box-wrap').on('click', '.cancle-btn', function (event) {
          event.stopPropagation();
          layer.close(index);
        });

        /* 确定按钮关闭弹窗 */
        $('.close-box-wrap').on('click', '.layer-enter-btn', function (event) {
          event.stopPropagation();
          layer.close(index);
        });
      }
    });
  });

  /* 考研真题 */
  $('.real-inner-box .r-list').on('click', 'li', function (event) {
    event.stopPropagation();
    layer.open({
      title: '',
      type: 1,
      closeBtn: 0, //不显示关闭按钮
      area: ['90%', '128px'], //宽高
      content: $('#js-real-box-wrap'),
      success: function ($dom, index) {
        $($dom).addClass('myRealLayer')

        /* 取消按钮关闭弹窗 */
        $('.close-box-wrap').on('click', '.cancle-btn', function (event) {
          event.stopPropagation();
          layer.close(index);
        });

        /* 确定按钮关闭弹窗 */
        $('.close-box-wrap').on('click', '.layer-enter-btn', function (event) {
          event.stopPropagation();
          layer.close(index);
          window.location.href="../真题内容.html";
        });
      }
    });
  });

});
layui.use('element', function () {
  var element = layui.element;
});